<?php
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile
/**
 * @see \Magento\Paypal\Block\System\Config\Fieldset\Hint
 * @var \Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Hint $block
 */
$helpLink = $block->escapeUrl($block->getHelpLink());
?>
<?php
if ($helpLink):
?>
    <div class="paypal-payment-notice">
        <?php echo $block->escapeHtml(__('Not sure what PayPal payment method to use? Click ')); ?>
        <a href="<?php /* @noEscape */
        echo $helpLink; ?>" target="_blank"><?php echo $block->escapeHtml(__('here')); ?></a>
        <?php echo $block->escapeHtml(__(' to learn more.')); ?>
    </div>
<?php
endif;
?>
<script>
require(['jquery', 'prototype'], function(jQuery){
    window.paypalToggleSolution = function (id, url) {
        var doScroll = false;
        Fieldset.toggleCollapse(id, url);
        if ($(this).hasClassName("open")) {
            $$(".with-button button.button").each(function(anotherButton) {
                if (anotherButton != this && $(anotherButton).hasClassName("open")) {
                    $(anotherButton).click();
                    doScroll = true;
                }
            }.bind(this));
        }
        if (doScroll) {
            var pos = Element.cumulativeOffset($(this));
            window.scrollTo(pos[0], pos[1] - 45);
        }
    }
});
</script>
